package widgets

import (
	"image"
	"image/color"
	"image/draw"
)

type Button struct {
	text             string
	img1, img2, img3 *image.RGBA // normal, hover, pressed
	DrawChan         chan *image.RGBA
}

func mkDefaultImg(bgcol color.Color) *image.RGBA {
	bgimg := image.NewUniform(bgcol)
	img := image.NewRGBA(image.Rect(0, 0, 30, 20))
	draw.Draw(img, img.Rect, image.Black, image.ZP, draw.Src)
	draw.Draw(img, img.Rect.Inset(1), bgimg, image.ZP, draw.Src)
	return img
}

func NewButton(text string) *Button {
	img1 := mkDefaultImg(color.RGBA{255, 255, 0, 255})
	img2 := mkDefaultImg(color.RGBA{255, 0, 255, 255})
	img3 := mkDefaultImg(color.RGBA{0, 255, 255, 255})
	dc := make(chan *image.RGBA)
	b := &Button{
		text:     text,
		img1:     img1,
		img2:     img2,
		img3:     img3,
		DrawChan: dc,
	}

	go b.start()
	return b
}

const (
	normal = iota
	hover
	pressed
)

func (b *Button) start() {
}
